home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
exbine.zip
/
BINED.HDR
< prev
next >
Wrap
Text File
|
1993-01-04
|
6KB
|
166 lines
{$I-}
{$S-}
{$R-}
unit BinEd;
{-The Borland binary editor interface for Turbo Pascal}
interface
const
MaxFileSize = $FFE0; {Maximum editable file size }
EdOptInsert = $1; {Insert on flag}
EdOptIndent = $2; {Autoindent on flag}
EdOptTAB = $8; {Tab on flag}
EdOptBlock = $10; {Show marked block}
EdOptNoUpdate = $20; {Don't update screen when entering editor}
EventKBflag = 1; {Scroll, num or caps locks modified mask}
CAnorm = #255#1; {Activates CRT "normal" attribute}
CAlow = #255#2; {Activates CRT "low" - }
CAblk = #255#3; {Activates CRT "block" - }
CAerr = #255#4; {Activates CRT "error" - }
EdStatTextMod = 1; {Text buffer modified mask}
type
AttrArray = array[0..3] of Byte;
ASCIIZ = array[0..255] of Char;
ASCIIZptr = ^ASCIIZ;
TextBuffer = array[0..$FFF0] of Char;
CRTinsStruct = {CRT installation structure}
record
CRTtype : Byte; {1=IBM, 0=Non}
CRTx1, CRTy1,
CRTx2, CRTy2 : Byte; {Initial window size}
CRTmode : Byte; {Initial mode 0-3,7 or FF(default)}
CRTsnow : Byte; {0 if no snow, don't care for mono}
AttrMono : AttrArray; {CRT attributes for mono mode}
AttrBW : AttrArray; {CRT attributes for b/w modes}
AttrColor : AttrArray; {CRT attributes for color modes}
end;
CIptr = ^CRTinsStruct;
EdInsStruct = {Command table installation structure}
record
ComTablen : Word; {Maximum length of command table}
ComTab : TextBuffer; {Command table}
end;
EIptr = ^EdInsStruct;
MIinsStruct = {Main installation structure}
record
Ver : Byte; {Main version}
VerSub : Byte; {Sub version}
VerPatch : Char; {Patch level}
CPUmhz : Byte; {CPU speed for delays}
CIstruct : CIptr; {Points to CRT installation record}
EIstruct : EIptr; {Points to Editor installation area}
DefExt : ASCIIZptr; {Points to ASCIIZ default extension}
end;
MIptr = ^MIinsStruct;
EdCB = {Editor control block in detail}
record
x1, y1, x2, y2 : Byte; {UL & LR corners of editor window}
DataSeg : Word; {Segment address of editor data area}
DataSegLen : Word; {Requested data area length (bytes)}
Options : Word; {Bit flags for editor options}
FileStr : ASCIIZptr; {Points to ASCIIZ filename}
Commands : ASCIIZptr; {Points to string of editor commands}
Place1 : ASCIIZptr; {Not used here}
Place2 : ASCIIZptr; {Not used here}
Event : Pointer; {Points to event handling procedure}
Buffer : ^TextBuffer; {Points to text area}
BufSize : Word; {Available size for text}
MIstruct : MIptr; {Points to main installation record}
ComTab : ASCIIZptr; {Points to terminate command table}
EOtext : Word; {Current number of chars in text buffer}
CursorPos : Word; {Current cursor position in buffer}
BlockStart : Word; {Start of marked block in buffer}
BlockEnd : Word; {End of marked block in buffer}
Status : Word; {Editor status}
DataPtr : ^TextBuffer; {Points to Turbo heap block }
end; { allocated for text buffer}
const
{CRT attributes for normal low blk error}
MonoArray : AttrArray = ($F, $7, $7, $70);
BwArray : AttrArray = ($F, $7, $7, $70);
ColorArray : AttrArray = ($E, $7, $3, $1E);
{-----------------------------------------------------------------}
procedure CRTputFast(x, y : Word; s : string);
{-Use binary editor services to write a string to the screen}
{x in 1..25, y in 1..80}
function ExpandPath(Fname : string) : string;
{-Return a complete path using the binary editor services}
function InitBinaryEditor(
var EdData : EdCb; {Editor control block}
DataLen : Word; {Size of binary editor workspace}
Cx1 : Byte; {Editor window, upper left x 1..80}
Cy1 : Byte; {Editor window, upper left y 1..25}
Cx2 : Byte; {Editor window, lower right x 1..80}
Cy2 : Byte; {Editor window, lower right y 1..25}
WaitForRetrace : Boolean; {True for snowy color cards}
Coptions : Word; {Initial editor options}
DefExtension : string; {Default file extension }
{ (must start with a period)!}
var ExitCommands; {Commands to exit editor}
UserEventProcPtr : Pointer {Pointer to user event handler}
) : Word;
{-Initialize the binary editor, returning a status code}
{
Status Codes -
0 = Successful initialization
1 = Insufficient memory space for text buffer
}
function ReadFileBinaryEditor(var EdData : EdCb;
Fname : string) : Word;
{-Read a file into the binary editor buffer space, }
{ returning a status code }
{
Status codes -
0 = Successful read
1 = File not found, new file assumed
2 = File too large to edit
}
procedure ResetBinaryEditor(var EdData : EdCb);
{-Call the editor reset procedure}
function UseBinaryEditor(var EdData : EdCb;
StartCommands : string) : Integer;
{-Edit file, using startcommands, and returning an exitcode}
{
Exit codes -
-1 = Editing terminated with ^KD
0 = Editing terminated with first user-specified exit command
1 ...
}
function ModifiedFileBinaryEditor(var EdData : EdCb) : Boolean;
{-Return true if text buffer was modified during edit}
function FileNameBinaryEditor(var EdData : EdCb) : string;
{-Return the current file pathname of the specified control block}
function SaveFileBinaryEditor(var EdData : EdCb;
MakeBackup : Boolean) : Word;
{-Save the current file in the editor text buffer,
{ returning a status code }
{
Status codes -
0 = Successful save
1 = File creation error
2 = Disk write error
3 = Error closing file
}
procedure ReleaseBinaryEditorHeap(var EdData : EdCb);
{-Release heap space used by a binary editor control block}